import type { IMenu } from '@/api/modules/auth/menu';
import { IS_ENUM } from '@/enum/system';
import type { Rule } from 'ant-design-vue/es/form';

const formObj: IMenu = {
  menuId: '',
  menuName: '',
  parentName: null,
  parentId: '0',
  orderNum: 0,
  path: '',
  component: '',
  isFrame: IS_ENUM.NOT,
  isCache: '',
  menuType: 'M',
  visible: IS_ENUM.IS,
  status: '',
  perms: '',
  icon: '',
  createBy: '',
  createTime: '',
  updateBy: '',
  updateTime: '',
  remark: '',
  params: undefined,
  children: [],
  meta: undefined,
};
export const form = ref({ ...formObj });

export const formRef = ref();

export const resetForm = () => {
  form.value = {
    ...formObj,
  };
};
export const formRules: Record<string, Rule[]> = {
  menuName: [{ required: true, trigger: 'blur' }],
  path: [{ required: true, trigger: 'blur' }],
  component: [{ required: true, trigger: 'blur' }],
  parentId: [{ required: true, trigger: 'blur' }],
  menuType: [{ required: true, trigger: 'blur' }],
};
